﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MealCardManagement.Client
{
    public partial class MoneyInputForm : Form
    {
        public decimal InputMoney { get; private set; }

        public MoneyInputForm()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            decimal value = 0;
            if (string.IsNullOrWhiteSpace(textBox.Text) || !decimal.TryParse(textBox.Text, out value))
            {
                MessageBox.Show("格式非法");
                return;
            }

            if ((value * 100) - (int)(value * 100) != 0)
            {
                MessageBox.Show("最多可有2位小数");
                return;
            }

            InputMoney = value;
            DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
